package cn.edu.scau.nursingcenter.service.impl;

import java.util.List;
import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.edu.scau.nursingcenter.dao.Check_inRepository;
import cn.edu.scau.nursingcenter.entiry.Check_in;
import cn.edu.scau.nursingcenter.service.Check_inService;


/**
 * 业务逻辑层接口实现类 Check_inServiceImpl
 * @author feng
 *
 */
@Service
public class Check_inServiceImpl implements Check_inService{
	
	@Autowired
	private Check_inRepository check_inRepository;

	/**
	 * 显示所有入住信息
	 * @return
	 */
	@Override
	public List<Check_in> selectAll() {	
		return check_inRepository.findAll();
	}

	/**
	 * 新增入住
	 * @param check_in
	 * @return
	 */
	@Override
	public Check_in insert(Check_in check_in) {	
		return check_inRepository.save(check_in);
	}

	/**
	 * 根据客户名字查询
	 * @param name
	 * @return
	 */
	@Override
	public List<Check_in> findByName(String name) {
		return check_inRepository.findByName(name);
	}

	/**
	 * 修改入住信息
	 * @param check_in
	 * @return
	 */
	@Override
	public Check_in update(Check_in check_in) {
		return check_inRepository.save(check_in);
	}

	/**
	 * 根据编号删除
	 * @param id
	 */
	@Override
	public void deleteById(Integer id) {
		check_inRepository.deleteById(id);
	}

	/**
	 * 根据客户编号查询
	 * @param id客户编号
	 * @return
	 */
	@Override
	public Check_in findById(Integer id) {
		Optional<Check_in> optional = check_inRepository.findById(id);
		return optional.isPresent()?optional.get():null;
	}



	

	
}
